package com.system.permissiondemo.util;


import org.apache.commons.lang3.StringUtils;

/**
* @Description:    层级工具类（当前业务使用）
* @Author:         Joe
* @CreateDate:     2020/3/25 13:42
*/
public class LevelUtil {
    //各个层级之间的分隔符
    public final static String SEPARATOR = ".";
    //ROOT的Id,从0开始
    public final static String ROOT = "0";

    /**
     * 部门level的计算规则
     * @param parentLevel
     * @param parentId
     * @return 0/0.1/0.1.2/0.1.2.3/
     */
    public static String calculateLevel(String parentLevel,Integer parentId){
        if (StringUtils.isBlank(parentLevel)){
            return ROOT;
        }else {
            return StringUtils.join(parentLevel, SEPARATOR, parentId);
        }
    }

    /*public static void main(String[] args) {
        String s = calculateLevel("0", 1);
        System.out.println(s);
    }*/

}
